package com.ddw.wotcg.client.threejs.renderers;

import com.ddw.wotcg.client.threejs.ShadowMapType;
import com.ddw.wotcg.client.threejs.cameras.Camera;
import com.ddw.wotcg.client.threejs.math.Color;
import com.ddw.wotcg.client.threejs.scenes.Scene;
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.JsArray;
import com.google.gwt.user.client.Element;

/**
 * http://mrdoob.github.com/three.js/docs/54/#Reference/Renderers/WebGLRenderer
 * 
 * @author fungus1487
 * 
 */
public final class WebGLRenderer extends Renderer {
	
	/**
	 * http://mrdoob.github.com/three.js/docs/54/#Reference/Renderers/
	 * WebGLRenderer
	 * 
	 * @author fungus1487
	 * 
	 */
	public static final class WebGLRendererInfo extends JavaScriptObject {
		
		protected WebGLRendererInfo() {
		}
		
	}
	
	/**
	 * http://mrdoob.github.com/three.js/docs/54/#Reference/Renderers/
	 * WebGLRenderer
	 * 
	 * @author fungus1487
	 * 
	 */
	public static final class WebGLRendererParameters extends JavaScriptObject {
		
		public static native WebGLRendererParameters create() /*-{
			return new {};
		}-*/;
		
		protected WebGLRendererParameters() {
		}
		
		public native void setAlpha(boolean alpha) /*-{
			this['alpha'] = alpha;
		}-*/;
		
		public native void setAntialias(boolean antialias) /*-{
			this['antialias'] = antialias;
		}-*/;
		
		public native void setCanvas(Element canvas) /*-{
			this['canvas'] = canvas;
		}-*/;
		
		public native void setClearAlpha(double clearAlpha) /*-{
			this['clearAlpha'] = clearAlpha;
		}-*/;
		
		public native void setClearColor(int clearColor) /*-{
			this['clearColor'] = clearColor;
		}-*/;
		
		public native void setMaxLights(int maxLights) /*-{
			this['maxLights'] = maxLights;
		}-*/;
		
		public native void setPrecision(String precision) /*-{
			this['precision'] = precision;
		}-*/;
		
		public native void setPremultipliedAlpha(boolean premultipliedAlpha) /*-{
			this['premultipliedAlpha'] = premultipliedAlpha;
		}-*/;
		
		public native void setPreserveDrawingBuffer(
				boolean preserveDrawingBuffer) /*-{
			this['preserveDrawingBuffer'] = preserveDrawingBuffer;
		}-*/;
		
		public native void setStencil(boolean stencil) /*-{
			this['stencil'] = stencil;
		}-*/;
		
	}
	
	public static native WebGLRenderer create() /*-{
		return new $wnd.THREE.WebGLRenderer();
	}-*/;
	
	public static native WebGLRenderer create(WebGLRendererParameters parameters) /*-{
		return new $wnd.THREE.WebGLRenderer(parameters);
	}-*/;
	
	protected WebGLRenderer() {
	}
	
	public native void addPostPlugin(JavaScriptObject plugin) /*-{
		this.addPostPlugin(plugin);
	}-*/;
	
	public native void addPrePlugin(JavaScriptObject plugin) /*-{
		this.addPrePlugin(plugin);
	}-*/;
	
	public native void enableScissorTest(boolean enable) /*-{
		this.enableScissorTest(enable);
	}-*/;
	
	public native boolean getAutoClearColor() /*-{
		return this.autoClearColor;
	}-*/;
	
	public native boolean getAutoClearDepth() /*-{
		return this.autoClearDepth;
	}-*/;
	
	public native boolean getAutoClearStencil() /*-{
		return this.autoClearStencil;
	}-*/;
	
	public native boolean getAutoScaleCubemaps() /*-{
		return this.autoScaleCubemaps;
	}-*/;
	
	public native boolean getAutoUpdateObjects() /*-{
		return this.autoUpdateObjects;
	}-*/;
	
	public native boolean getAutoUpdateScene() /*-{
		return this.autoUpdateScene;
	}-*/;
	
	public native double getClearAlpha() /*-{
		return this.getClearAlpha();
	}-*/;
	
	public native Color getClearColor() /*-{
		return this.getClearColor();
	}-*/;
	
	public native JavaScriptObject getContext() /*-{
		return this.getContext();
	}-*/;
	
	public native boolean getGammaInput() /*-{
		return this.gammaInput;
	}-*/;
	
	public native boolean getGammaOutput() /*-{
		return this.gammaOutput;
	}-*/;
	
	public native WebGLRendererInfo getInfo() /*-{
		return this.info;
	}-*/;
	
	public native int getMaxMorphNormals() /*-{
		return this.maxMorphNormals;
	}-*/;
	
	public native int getMaxMorphTargets() /*-{
		return this.maxMorphTargets;
	}-*/;
	
	public native boolean getPhysicallyBasedShading() /*-{
		return this.physicallyBasedShading;
	}-*/;
	
	public native JsArray<JavaScriptObject> getRenderPluginsPost() /*-{
		return this.renderPluginsPost;
	}-*/;
	
	public native JsArray<JavaScriptObject> getRenderPluginsPre() /*-{
		return this.renderPluginsPre;
	}-*/;
	
	public native boolean getShadowMapAutoUpdate() /*-{
		return this.shadowMapAutoUpdate;
	}-*/;
	
	public native boolean getShadowMapCascade() /*-{
		return this.shadowMapCascade;
	}-*/;
	
	public native boolean getShadowMapCullFrontFaces() /*-{
		return this.shadowMapCullFrontFaces;
	}-*/;
	
	public native boolean getShadowMapDebug() /*-{
		return this.shadowMapDebug;
	}-*/;
	
	public native boolean getShadowMapEnabled() /*-{
		return this.shadowMapEnabled;
	}-*/;
	
	public native ShadowMapType getShadowMapType() /*-{
		return this.shadowMapType;
	}-*/;
	
	public native void initWebGLObjects(Scene scene) /*-{
		this.initWebGLObjects(scene);
	}-*/;
	
	public native void render(Scene scene, Camera camera,
			WebGLRenderTarget renderTarget, boolean forceClear) /*-{
		this.render(scene, camera, renderTarget, forceClear);
	}-*/;
	
	public native void setScissor(int x, int y, int width, int height) /*-{
		this.setScissor(x, y, width, height);
	}-*/;
	
	public native void setViewport(int x, int y, int width, int height) /*-{
		this.setViewport(x, y, width, height);
	}-*/;
	
	public native void updateShadowMap(Scene scene, Camera camera) /*-{
		this.updateShadowMap(scene, camera);
	}-*/;
	
}
